package com.jk.cxh.controller;

import com.jk.MovieBean;
import com.jk.MovieHallBean;
import com.jk.ProgramBean;
import com.jk.cxh.server.PlanMovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.util.List;

/**
 * @Author 程旭航
 * @Create 2021/5/19 - 16:27
 * @Description
 */
@RestController
@RequestMapping("plan")
public class PlanMovieController {

    @Autowired
    private PlanMovieService cxhMovieService;

    //获取影厅数量
    @GetMapping("hallCount")
    public List<MovieHallBean> hallCount(Integer id){
        List<MovieHallBean> list= cxhMovieService.hallCount(id);
        return list;
    }

    //新增电影计划
    @PostMapping("addplay")
    public String addplay(ProgramBean program, HttpSession session) throws ParseException {
        return cxhMovieService.addplay(program,session);
    }


    //查询电影
    @GetMapping("findMovies")
    public MovieBean findMovies(String name){
        MovieBean MovieBean=cxhMovieService.findMovies(name);
        return  MovieBean;
    }

    ///** 查看影厅播放计划
    @GetMapping("queryPlan")
    public List<ProgramBean> queryPlan(String dateTime,Integer id,Integer hallId)  {
        List<ProgramBean> list = cxhMovieService.queryPlan(dateTime, id, hallId);
        return  list;
    }

    /**
     * @Author:程旭航
     * @Description:
     * @Date: 2021/6/7 21:25
     * @param
     * @Return:
     **/
    @GetMapping("queryMovie")
    public List<MovieBean> queryMovie( ){
        List<MovieBean> list= cxhMovieService.queryMovie();
        return list;

    }

    @GetMapping("queryPrice")
    public Double queryPrice(Integer cinemaId,Integer movieId){
        return cxhMovieService. queryPrice( cinemaId, movieId);
    }

    @GetMapping("endDate")
    public String endDate(Integer movid,String date) throws ParseException {
        return cxhMovieService. endDate( movid, date);
    }




}
